<template>
  <div v-if="phb[0]">
     <div class="user-phb"><!--{{phb[0].uname}} -->
      <div class="phb_bs">
        <div class="phb_d2">
          <div>
            <img :src="phb[1].headp" alt="" class="bjt">
            <div class="d2_s">
              <div>
                <div class="d2_gh"></div>
                <img :src="phb[1].headp" alt="">
              </div>             
              <div>
                <span>{{phb[1].uname}}</span>
              </div>
            </div>
            <div class="d2_x">
              <span>{{phb[1].signature}}</span>
              <div>
                <span>人气-{{phb[1].zl}}</span>
                <span>粉丝-{{phb[1].fans}}</span>
                <span>点赞-{{phb[1].ulike}}</span>
              </div>
              <span @click="tofans(phb[1].uname)">关注</span>
            </div>
          </div>
        </div>
        <div class="phb_d1">
          <div>
            <img :src="phb[0].headp" alt="" class="bjt">
            <div class="d1_s">
              <div>
                <div class="d1_gh"></div>
                <div class="d1_gh1 d1_gh"></div>
                <img :src="phb[0].headp" alt="">
              </div>
              
              <div>
                <span>{{phb[0].uname}}</span>
              </div>
            </div>
            <div class="d1_x">
              <span>{{phb[0].signature}}</span>
              <div>
                <span>人气-{{phb[0].zl}}</span>
                <span>粉丝-{{phb[0].fans}}</span>
                <span>点赞-{{phb[0].ulike}}</span>
              </div>
              <span @click="tofans(phb[0].uname)">关注</span>
            </div>
          </div>
        </div>
        <div class="phb_d3">
          <div>
            <img :src="phb[2].headp" alt="" class="bjt">
            <div class="d3_s">
              <div>
                <div class="d3_gh"></div>
                <img :src="phb[2].headp" alt="">
              </div>
              <div>
                <span>{{phb[2].uname}}</span>
              </div>
            </div>
            <div class="d3_x">
              <span>{{phb[2].signature}}</span>
              <div>
                <span>人气-{{phb[2].zl}}</span>
                <span>粉丝-{{phb[2].fans}}</span>
                <span>点赞-{{phb[2].ulike}}</span>
              </div>
              <span @click="tofans(phb[2].uname)">关注</span>
            </div>
          </div>
        </div>
      </div>
      <div class="phb_bw">
        <div>
          <div class="phb_bt">
            <div>头像</div>
            <div>姓名</div>
            <div>人气</div>
            <div>粉丝</div>
            <div>点赞</div>
            <div>关注</div>

          </div>
          <div v-for="i in 7" :key="i" class="phb_bw_bd">
              <div><img :src="phb[i+2].headp" alt=""></div>
              <span>{{phb[i+2].uname}}</span>
              <span>{{phb[i+2].zl}}</span>
              <span>{{phb[i+2].fans}}</span>
              <span>{{phb[i+2].ulike}}</span>
              <div>
                <span @click="tofans(phb[i+2].uname)">关注</span>
              </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script src="../vendor/jquery-3.6.0.js"></script>
<script>
import { mapMutations, mapState } from 'vuex'
  export default {
    computed:{
      ...mapState(["loginname"],["loginshow"])
    },
    data() {
      return {
        phb: []
      }
    },
    methods: {
      ...mapMutations(["setls"]),
      getphb() {
        const url="/phblist"
        this.axios.get(url).then((res)=>{
          // console.log(res)
          this.phb=res.data.data
          // console.log(this.phb)
        })
      },
      tofans(i){
        // console.log(i)
        // 如果已经登录非空则添加，否则弹出登录框
        if(!this.loginname){
          var rs=confirm('还未登录，前去登录？')
          if(rs){
            this.setls(true)
          }else{
            return
          }
        }
        const url="/fans"
        const params=`uname=${this.loginname}&focus_uname=${i}`
        this.axios.post(url,params).then((res)=>{
          console.log(res)
          if(res.data.code==200){
            alert('关注成功')
          }
        })
      }
    },
    
    mounted(){
      this.getphb()
    }
  }
</script>

<style lang="scss">
  *{
    margin: 0;
    padding: 0;
  }
  @keyframes xz{
				0%{transform: rotate(0deg);}
				100%{transform: rotate(360deg);}
	}
  
  .user-phb{
    width: 1200px;
    margin: 0 auto;
    // background-color: rgba(252, 248, 0, 0.1);
    // border: 1px solid red;
    padding-top: 25px;
    .phb_bs{
      position: relative;
      width: 80%;
      margin: 15px auto;
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      // border: 2px dashed yellow;
      border-radius: 35px;
      padding: 15px 0;
      .phb_d2{
        width: 30%;
        height: 170px;
        >div{
          width: 80%;
          margin: 0 auto;
          position: relative;
          .bjt{
            position: absolute;
            z-index: -1;
            width: 230px;
            height: 170px;
            opacity:0.3;
            border-radius: 25px;
          }
          .d2_s{
            display: flex;
            width: 45%;
            margin: 0 auto;
            padding-top: 15px;
            >div:first-child{
              transition: 0.5s;
              &:hover{
                transform: scale(1.2);
              }
            }
            img{
              width: 70px;
              border-radius: 50%;
            }
            div:last-child{
              width: 20px;
              height: 70px;
              margin-left: 18px;
              display: flex;
              flex-direction: column;
              align-items: flex-end;
              margin-top: -5px;
              span{
                margin: auto 0;
                font-size: 15px;
              }
            }
            .d2_gh{
              position: absolute;
              width: 80px;
              height: 80px;
              border-radius: 50%;
              border: 2px dashed red;
              margin-left: -7px;
              margin-top: -7px;
              border-top-color: #ffff00;
              border-bottom-color: #ff0;
              transition: 0.1s;
              animation:xz 1s infinite linear;
            }
          }
          .d2_x{
            margin: 10px auto;
            width: 80%;
            >span{
              display: block;
              text-align: center;
              line-height: 25px;
              font-size: 15px;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
            }
            >div{
              display: flex;
              >span{
                display: inline-block;
                width: 33%;
                text-align: center;
                font-size: 14px;
              }
            }
            >span:last-child{
              display: block;
              width: 50px;
              line-height: 20px;
              border-radius: 10px;
              background-color: rgb(241, 45, 45);
              color: #fff;
              margin: 0 auto;
              margin-top: 4px;
            }
          }
        }
      }
      .phb_d1{
        width: 45%;
        height: 250px;
        >div{
          width: 80%;
          margin: 0 auto;
          position: relative;
          .bjt{
            position: absolute;
            z-index: -1;
            width: 345px;
            height: 250px;
            opacity:0.4;
            border-radius: 50px;
          }
          .d1_s{
            display: flex;
            width: 45%;
            margin: 0 auto;
            padding-top: 35px;
            >div:first-child{
              transition: 0.5s;
              &:hover{
                transform: scale(1.2);
              }
            }
            img{
              width: 100px;
              border-radius: 50%;
            }
            div:last-child{
              width: 25px;
              height: 100px;
              margin-left: 25px;
              display: flex;
              flex-direction: column;
              align-items: flex-end;
              margin-top: -15px;
              span{
                margin: auto 0;
                font-size: 25px;
              }
            }
            .d1_gh{
              position: absolute;
              width: 110px;
              height: 110px;
              border-radius: 50%;
              border: 2px dashed red;
              margin-left: -7px;
              margin-top: -7px;
              border-top-color: #ffff00;
              border-bottom-color: #ff0;
              transition: 0.1s;
              animation:xz 1s infinite linear;
            }
            .d1_gh1{
              width: 120px;
              height: 120px;
              margin-left: -12px;
              margin-top: -12px;
              border: 2px dashed #ff0;
              border-top-color: red;
              border-bottom-color: red;
            }
          }
          .d1_x{
            margin: 20px auto;
            width: 80%;
            >span{
              display: block;
              text-align: center;
              line-height: 35px;
              font-size: 18px;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
            }
            >div{
              display: flex;
              >span{
                display: inline-block;
                width: 33%;
                text-align: center;
              }
              margin-bottom: 5px;
            }
            >span:last-child{
              display: block;
              width: 60px;
              line-height: 25px;
              border-radius: 15px;
              background-color: rgb(251, 0, 0);
              color: #fff;
              margin: 0 auto;
            }
          }
        }
      }
      .phb_d3{
        width: 25%;
        height: 140px;
        >div{
          width: 80%;
          margin: 0 auto;
          position: relative;
          .bjt{
            position: absolute;
            z-index: -1;
            width: 192px;
            height: 140px;
            opacity:0.2;
            border-radius: 20px;
          }
          .d3_s{
            display: flex;
            width: 45%;
            margin: 0 auto;
            padding-top: 8px;
            >div:first-child{
              transition: 0.5s;
              &:hover{
                transform: scale(1.2);
              }
            }
            img{
              width: 60px;
              border-radius: 50%;
            }
            div:last-child{
              width: 20px;
              height: 70px;
              margin-left: 18px;
              display: flex;
              flex-direction: column;
              align-items: flex-end;
              margin-top: -5px;
              span{
                margin: auto 0;
                font-size: 12px;
              }
            }
            .d3_gh{
              position: absolute;
              width: 70px;
              height: 70px;
              border-radius: 50%;
              border: 2px dashed red;
              margin-left: -7px;
              margin-top: -7px;
              border-top-color: #ffff00;
              border-bottom-color: #ff0;
              transition: 0.1s;
            }
          }
          .d3_x{
            margin: 4px auto;
            width: 80%;
            >span{
              display: block;
              text-align: center;
              line-height: 18px;
              font-size: 15px;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
            }
            >div{
              display: flex;
              >span{
                font-size: 14px;
                display: inline-block;
                width: 33%;
                text-align: center;
                font-size: 10px;
              }
            }
            >span:last-child{
              display: block;
              width: 45px;
              line-height: 20px;
              border-radius: 10px;
              background-color: #fc2b55;
              color: #fff;
              margin: 0 auto;
              font-size: 14px;
              margin-top: 3px;
            }
          }
        }
      }
    }
    .phb_bw{
      width: 80%;
      margin: 15px auto;
      display: flex;
      flex-direction: column;
      // border: 2px dashed yellow;
      border-radius: 10px;
      padding: 15px 0;
      
      >div{
        width: 90%;
        margin: 0 auto;
        .phb_bt{
          display: flex;
          div{
            width: 20%;
            text-align: center;
          }
        }
        .phb_bw_bd{
          display: flex;
          margin: 10px auto;
          border: 1px solid #c1c1c1 ;
          border-radius: 10px;
          cursor: pointer;
          align-items: center;
          div{
            width: 20%;
            img{
              display: block;
              width: 45px;
              height: 45px;
              margin: 0 auto;
              border-radius: 50%;
            }
           
          }
          span{
            width: 20%;
            line-height: 40px;
            text-align: center;
          }
          // :first-child{
          //   width: 100px;
          //   height: 40px;
          //   display: flex;
          //   justify-content: center;
          //   align-items: center;
          // }
          // :last-child{
          //   background-color: #fc2b55;
          //   color: white;
          //   border-radius: 10px;
          //   width: 50px;
          //   height: 40px;
          // }
          div:last-child{
            text-align: center;
            >span{
              background-color: #fc2b55;
              display: block;
              color: white;
              margin: 0 auto;
              border-radius: 15px;
              font-size: 12px;
              width: 45px;
              line-height: 25px;
            }
          }
        }
      }
    }
  }
</style>